home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4763 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.5 KB

  1. Path: news.uiowa.edu!usenet
  2. From: larued@crpl.cedar-rapids.lib.ia.us
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Compile problem
  5. Date: 1 Feb 1996 01:01:07 GMT
  6. Organization: University of Iowa, Iowa City, IA, USA
  7. Distribution: world
  8. Message-ID: <4ep3cj$nho@flood.weeg.uiowa.edu>
  9. References: <4eol9k$gqf@fred.uswnvg.com>
  10. Reply-To: larued@crpl.cedar-rapids.lib.ia.us
  11. NNTP-Posting-Host: ppp-109.cedar-rapids.lib.ia.us
  12. X-Newsreader: IBM NewsReader/2 v1.9d - NLS
  13.  
  14. In <4eol9k$gqf@fred.uswnvg.com>, jweddle@uswnvg.com (Jacque Weddle) writes:
  15. >Hello,
  16. >
  17. >I'm a c person trying to compile some c++ code I got
  18. >off the net. I get the error message 
  19. >
  20. >"Log.cc", line 261: error: jump past initializer (did you forget a '{ }'?)
  21. >
  22. >I don't see a problem at the designated line number. Whats an
  23. >initializer?
  24. >I know this isn't much information but if someone could please 
  25. >tell me what kind of thing I should look for to fix this I'd much
  26. >appreciate it.
  27. >
  28. >TIA,
  29. >Jacque
  30. >
  31.  
  32.   Jacque,
  33.  
  34.   Code would have helped.  However, I've recently seen the problem.
  35.  
  36.   The problem is creating and initializing objects inside branch logic.
  37.  
  38.   For instance, creating objects inside a switch statement will cause this
  39. error.
  40.  
  41.  
  42. ===== Example code fragment
  43.   ...
  44.  
  45.   switch (X)
  46.    {
  47.      case 0 : Y = 0; break;
  48.      case 1 : int K; break;  // K is an object that can skip being initialized
  49.      default: Z = 0; break;
  50.    }
  51.  
  52. // K's scope is the entire fragment; not just the switch's {}.  If two K's were
  53. // declared (say case 0 and case 1) a duplicate define error would occur.
  54.  
  55. =====
  56.  
  57.  
  58.   Hope this helps,
  59.  
  60.     Dave
  61.